package com.example.bookservice.dsl;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.example.bookservice.entity.Book;
import com.example.bookservice.entity.Chapter;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 *  es 章节实体
 */
@Data
public class ChapterDSL {
    private static final long serialVersionUID = 1L;

    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long chapterId;
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long bookId;
    private String title;
    private String content;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime publicationDate;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateDate;
    private Boolean isApproved;
    private Boolean isAvailable;
    private List<String> suggestion;

    public ChapterDSL(Chapter chapter) {
        this.chapterId = chapter.getChapterId();
        this.bookId = chapter.getBookId();
        this.title = chapter.getTitle();
        this.content = chapter.getContent();
        this.publicationDate = chapter.getPublicationDate();
        this.updateDate = chapter.getUpdateDate();
        this.isApproved = chapter.getIsApproved();
        this.isAvailable = chapter.getIsAvailable();

        this.suggestion = Collections.singletonList(this.title);
    }
}
